🐊 主题曲 🐊
我们的政策是让一部分人、一部分地区先富起来,以带动和帮助落后的地区,先进地区帮助落后地区是一个义务。
————邓小平1986年3月28日在会见新西兰总理朗伊时说
《万般皆下品,唯有读书高》
习李经济,一带一路;
九二共识,量化对冲。
鞭策六四,铲除黑帮;(尤其是东南亚巫师Judi邪教宦官巫裔博彩庄诸国屠杀630万人类)
推广量化,提倡学术。
百家争鸣,振兴中华;
学海无涯,唯勤是岸。
世间再无祖父黄实田,家翁ξηg Tεηg,外祖母郑邓
FRA : Elle me dit
CHN : 她对我说
ENG : She told me
JPN : 彼女は私に言う
FRA : écris une chanson contente
CHN : 写一首欢快的歌
ENG : Write a happy song
JPN : 幸せな歌を書く
FRA : Pas une chanson déprimante
CHN : 而不是悲伤的歌
ENG : Not a depressing song
JPN : 気のめいるような歌ではない
FRA : Une chanson que tout le monde aime
CHN : 一首让所有人都喜欢的歌
ENG : A song that everyone loves
JPN : みんなが大好きな曲
FRA : Elle me dit
CHN : 她对我说
ENG : She told me
JPN : 彼女は私に言う
FRA : Tu deviendras milliardaire
CHN : 你将成为亿万富翁
ENG : You will become a millionaire
JPN : あなたは億万長者になります
FRA : Tu auras de quoi être fier
CHN : 你将为此感到骄傲
ENG : You will be proud
JPN : あなたは誇りに思うでしょう
# install.packages('remotes', dependencies = TRUE, INSTALL_opts = '--no-lock')
library('BBmisc', 'rmsfuns')
#remotes::install_github("rstudio/sass")
lib('sass')
## Loading required package: sass
## sass
## TRUE
## https://support.rstudio.com/hc/en-us/articles/200532197
## https://community.rstudio.com/t/r-does-not-display-korean-chinese/30889/3?u=englianhu
#Sys.setlocale("LC_CTYPE", "en_US.UTF-8")
#Sys.setlocale("LC_CTYPE", "zh_CN.UTF-8")
#Sys.setlocale(category = "LC_CTYPE", "Chinese (Simplified)_China.936")
#Sys.setlocale(locale = "Chinese")
#Sys.setlocale(locale = "Japanese")
#Sys.setlocale(locale = "English")
# rmarkdown::render('/home/englianhu/Documents/owner/ryo-cn.Rmd', encoding = 'UTF-8')
#Sys.setlocale("LC_CTYPE", "UTF-8")
#Sys.setlocale(locale = "UTF-8")
#Sys.setlocale(category = "LC_ALL", locale = "chs")
#Sys.setlocale(category = "LC_ALL", locale = "UTF-8")
#Sys.setlocale(category = "LC_ALL", locale = "Chinese")
#Sys.setlocale(category = "LC_ALL", locale = "zh_CN.UTF-8")
Sys.setlocale("LC_ALL", "en_US.UTF-8")
## [1] "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C"
/* https://stackoverflow.com/a/66029010/3806250 */
h1 { color: #002C54; }
h2 { color: #2F496E; }
h3 { color: #375E97; }
h4 { color: #556DAC; }
h5 { color: #92AAC7; }
/* ----------------------------------------------------------------- */
/* https://gist.github.com/himynameisdave/c7a7ed14500d29e58149#file-broken-gradient-animation-less */
.hover01 {
/* color: #FFD64D; */
background: linear-gradient(155deg, #EDAE01 0%, #FFEB94 100%);
transition: all 0.45s;
&:hover{
background: linear-gradient(155deg, #EDAE01 20%, #FFEB94 80%);
}
}
.hover02 {
color: #FFD64D;
background: linear-gradient(155deg, #002C54 0%, #4CB5F5 100%);
transition: all 0.45s;
&:hover{
background: linear-gradient(155deg, #002C54 20%, #4CB5F5 80%);
}
}
.hover03 {
color: #FFD64D;
background: linear-gradient(155deg, #A10115 0%, #FF3C5C 100%);
transition: all 0.45s;
&:hover{
background: linear-gradient(155deg, #A10115 20%, #FF3C5C 80%);
}
}
## 更换时间区域,保留日期时间。
Sys.setenv(TZ = 'Asia/Shanghai')
## 忽略所有警讯
## https://stackoverflow.com/a/36846793/3806250
## 设置宽度
## options(knitr.table.format = 'html')将所有kableExtra图表一致设置为'html'格式,省略设置各别图表。
options(warn = -1, width = 999, knitr.table.format = 'html')#, digits.secs = 6)
## https://stackoverflow.com/questions/39417003/long-vectors-not-supported-yet-abnor-in-rmd-but-not-in-r-script
## https://yihui.org/knitr/options
knitr::opts_chunk$set(
class.source = 'hover01', class.output = 'hover02', class.error = 'hover03',
message = FALSE, warning = FALSE, error = TRUE,
autodep = TRUE, aniopts = 'loop',
progress = TRUE, verbose = TRUE,
cache = FALSE, cache.lazy = FALSE, result = 'asis')
读取以下所需程序包。
## 读取程序包、设置编织与环境选项。
## 3210448065@qq.com
## leiou123
## 2849108450@qq.com
## leiou123
## https://rstudio.cloud/project/1198888
## 读取'BBmisc'程序包。
if(suppressMessages(!require('BBmisc'))){
install.packages('BBmisc', dependencies = TRUE, INSTALL_opts = '--no-lock')
suppressMessages(library('BBmisc'))
}
if (suppressMessages(!require('rmsfuns'))) {
install.packages('rmsfuns', dependencies = TRUE, INSTALL_opts = '--no-lock')
suppressMessages(library('rmsfuns'))
}
if(!require('REmap')) devtools::install_github('lchiffon/REmap')
## 一次性读取所需程序包。
library('dplyr', warn.conflicts = FALSE)
library('lubridate', warn.conflicts = FALSE)
conflict_prefer('filter', 'dplyr')
conflict_prefer('select', 'dplyr')
conflict_prefer('mutate', 'dplyr')
conflict_prefer('rename', 'dplyr')
conflict_prefer('collapse', 'dplyr')
conflict_prefer('year', 'lubridate')
pkgs <- c('devtools', 'knitr', 'kableExtra', 'tint', 'furrr', 'tidyr',
'readr', 'lubridate', 'data.table', 'reprex', 'stringr',
'feather', 'purrr', 'quantmod', 'tidyquant', 'tibbletime',
'timetk', 'plyr', 'dplyr', 'dbplyr', 'magrittr', 'sarima',
'tidyverse', 'memoise', 'htmltools', 'formattable', 'dtplyr',
'zoo', 'forecast', 'seasonal', 'seasonalview', 'rjson',
'rugarch', 'rmgarch', 'mfGARCH', 'sparklyr', 'jcolors', 'TSA',
'microbenchmark', 'dendextend', 'lhmetools', 'gtools',
'stringr', 'pacman', 'profmem', 'ggthemes', 'flyingfox',
'htmltools', 'echarts4r', 'viridis', 'hrbrthemes',
'fable', 'fabletools', 'Rfast', 'Metrics', 'MLmetrics')
# load_pkg(pkgs)
suppressAll(lib(pkgs))
load_pkg(pkgs)
rm(pkgs)
.路径 <- '/home/englianhu/Documents/GitHub/binary.com-interview-question-data/'
## 设置googleVis选项,促使plot.gvis只陈列HTML格式的完成品。
谷歌绘图设置 <- options(gvis.plot.tag = 'chart')
## <audio src='文艺坊曲库/bigmoney.mp3' autoplay controls loop></audio>
conflict_prefer('filter', 'dplyr')
conflict_prefer('select', 'dplyr')
conflict_prefer('mutate', 'dplyr')
conflict_prefer('rename', 'dplyr')
conflict_prefer('collapse', 'dplyr')
conflict_prefer('year', 'lubridate')
conflict_prefer('permutations', 'gtools')
Deriv.com - Interday High Frequency Trading Models Comparison Blooper科研论文中提及一些技术问题,故此使用Part I中的数据加以修饰并回测,再与Part II比较,筛选最优统计模型。
在此论文中,使用季节性自回归综合滑均模型系列。
msts())进程进度函数
运算进度表 <- function(导入数据, 起点 = NULL, 秒计 = 60, .匹配元素 = '^季节性自回归_', .周期性 = TRUE) {
## ------------- 定时查询进度 ----------------------
## 每分钟自动查询与更新以上模拟预测汇价进度(储存文件量)。
require('magrittr')
require('tibble')
if(!is.data.frame(class(导入数据))) {
导入数据 %<>% data.frame
}
if (.周期性 == TRUE) {
while(1) {
cat('当前中国标准时间:', as.character(now('Asia/Shanghai')), '\n\n')
日子 = as_date(导入数据$年月日时分) %>%
unique
#过滤并忽略每周闭市价时间 --- 周六凌晨12点,然后每周闭市价时间点为周五11:59PM。
日子 <- 日子[weekdays(日子) != 'Saturday']
动态日 = 日子
if(is.null(起点)) {
起点 = 日子[1]
} else if (is.Date(起点)) {
起点 = as_date(起点)
} else {
起点 = as_date(导入数据$年月日时分) %>%
unique
}
日子 = 日子[日子 >= 起点]
布告栏 = list.files(
paste0(.路径, 'data/fx/USDJPY/'), pattern = .匹配元素) %>%
str_replace_all('.rds', '') %>%
str_replace_all('.201', '_201') %>%
str_split_fixed('_', '2') %>%
as_tibble %>%
rename('统计模型' = 'V1', '日期' = 'V2') %>%
mutate(统计模型 = factor(统计模型), 日期 = as_date(日期))
布告栏 = join(tibble(日期 = 动态日), 布告栏) %>%
as_tibble
布告栏 %<>% na.omit
布告栏 %<>% mutate(有否 = if_else(is.na(统计模型), 0, 1)) %>%
spread(统计模型, 有否)
布告栏进度表 <- ldply(布告栏[,-1], function(布告栏参数) {
na.omit(布告栏参数) %>% length }) %>%
rename(进度 = V1) %>%
mutate(完成 = length(日子), 进度 = percent(进度/完成))
print(布告栏进度表)
进度表 = sum(布告栏进度表$进度)/sum(布告栏进度表$完成)
cat('\n================', as.character(percent(进度表)), '================\n\n')
if (进度表 == 1) break #倘若进度达到100%就停止更新。
Sys.sleep(秒计) #以上ldply()耗时3~5秒,而休息时间60秒。
}
} else {
cat('当前中国标准时间:', as.character(now('Asia/Shanghai')), '\n\n')
日子 = as_date(导入数据$年月日时分) %>%
unique
动态日 = 日子
if(is.null(起点)) {
起点 = 日子[1]
} else if (is.Date(起点)) {
起点 = as_date(起点)
} else {
起点 = as_date(导入数据$年月日时分) %>%
unique
}
日子 = 日子[日子 >= 起点]
布告栏 = list.files(paste0(.路径, 'data/fx/USDJPY/'), pattern = .匹配元素) %>%
str_replace_all('.rds', '') %>%
str_replace_all('.201', '_201') %>%
str_split_fixed('_', '2') %>%
as_tibble %>%
rename('统计模型' = 'V1', '日期' = 'V2') %>%
mutate(统计模型 = factor(统计模型), 日期 = as_date(日期))
布告栏 = join(tibble(日期 = 动态日), 布告栏) %>%
as_tibble
布告栏 %<>% na.omit
布告栏 %<>% mutate(有否 = if_else(is.na(统计模型), 0, 1)) %>%
spread(统计模型, 有否)
布告栏进度表 <- ldply(布告栏[,-1], function(布告栏参数) {
na.omit(布告栏参数) %>% length }) %>%
rename(进度 = V1) %>%
mutate(完成 = length(日子), 进度 = percent(进度/完成))
print(布告栏进度表)
进度表 = sum(布告栏进度表$进度)/sum(布告栏进度表$完成)
cat('\n================', as.character(percent(进度表)), '================\n\n')
}
}
Part I中使用的原始数据已加以修饰并储存,Part II与Part III次论文读取该数据,将网页轻巧化、省略掉修饰数据的一栏。
## 检验是否已设置路径。
if(!exists('.路径')) {
.路径 <- '/home/englianhu/Documents/GitHub/binary.com-interview-question-data/'}
## 倘若该路径尚无文件,储存文件。
if(!file.exists(paste0(.路径, 'data/fx/USDJPY/dsmp.rds')) & exists('样本')) {
saveRDS(样本, paste0(.路径, 'data/fx/USDJPY/dsmp.rds'))}
## 倘若环境尚未有数据,读取文件数据。
if(!exists('样本')) {
样本 <- readRDS(paste0(.路径, 'data/fx/USDJPY/dsmp.rds'))}
样本 %<>%
rename(
年月日时分 = index, 年份 = year, 季度 = quarter, 月份 = month, 周 = week, 周日 = wkdays,
周分计 = wk_1m, 日分计 = dy_1m, 时分计 = hr_1m, 序列 = sq, 日期 = date, 闭市价 = close)
## 绘制样本图表
样本[c(1:3, (nrow(样本)-3):nrow(样本)),] %>%
kbl(caption = '每分钟价位', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
## https://public.tableau.com/en-us/gallery/100-color-palettes?gallery=votd
row_spec(0, background = 'DimGrey', color = 'gold', bold = TRUE) %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = 'Gray') %>%
column_spec(3, background = 'DarkGrey') %>%
column_spec(4, background = 'Gray') %>%
column_spec(5, background = 'DarkGrey') %>%
column_spec(6, background = '#4897D8') %>%
column_spec(7, background = '#556DAC') %>%
column_spec(8, background = '#92AAC7') %>%
column_spec(9, background = '#556DAC') %>%
column_spec(10, background = '#375E97') %>%
column_spec(11, background = 'CornflowerBlue') %>%
column_spec(12, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
##`full_width = FALSE`是将每列设置为伸缩性自动调整宽度。
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE, height = '400px')
| 年月日时分 | 年份 | 季度 | 月份 | 周 | 周日 | 周分计 | 日分计 | 时分计 | 序列 | 日期 | 闭市价 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 2015-01-04 23:01:00 | 2015 | 1 | 1 | 1 | Monday | 1 | 1 | 1 | 1 | 2015-01-05 | 120.5740 |
| 2015-01-04 23:02:00 | 2015 | 1 | 1 | 1 | Monday | 2 | 2 | 2 | 2 | 2015-01-05 | 120.5900 |
| 2015-01-04 23:03:00 | 2015 | 1 | 1 | 1 | Monday | 3 | 3 | 3 | 3 | 2015-01-05 | 120.6035 |
| 2018-07-06 22:57:00 | 2018 | 3 | 7 | 27 | Friday | 7197 | 1437 | 57 | 1324797 | 2018-07-06 | 110.4635 |
| 2018-07-06 22:58:00 | 2018 | 3 | 7 | 27 | Friday | 7198 | 1438 | 58 | 1324798 | 2018-07-06 | 110.4740 |
| 2018-07-06 22:59:00 | 2018 | 3 | 7 | 27 | Friday | 7199 | 1439 | 59 | 1324799 | 2018-07-06 | 110.4740 |
| 2018-07-06 23:00:00 | 2018 | 3 | 7 | 27 | Saturday | 7200 | 1440 | 60 | 1324800 | 2018-07-07 | 110.4740 |
数据 : 1324800行 x 12列
以上图表显示数据日期,由2015-01-05 至 2018-07-07,而该数据也是在论文(Part I)、(Part II)中使用,并且相符。使用同样的数据,是为了在回测多元统计模型,才能获知并筛选最优统计模型。
在此先过滤数据,从2016年的第一个预测日(2016-01-04开始,也就是读取的样本数据中的第二年数据开始),与论文(Part I)、(Part II)中相符。
ARIMA(p,d,q)模型中
- p是自回归(AR)的项数,用来获取自变量
- d是差分(I)的系数,为了使时间序列平稳
- q是移动平均(MA)的项数,为了使其光滑
引用:ARIMA模型中的三个参数(p, d, q)都是什么意思?
运用SPSS 19.0软件中的相关模块进行数据处理和分析。本研究是以月份为时间单位的研究序列,故选择复合季节模型[5, 6]:ARIMA(p,d,q)(P,D,Q)s,参数p为非季节性自回归阶数,d为一般差分阶数,q为非季节性滑动平均阶数;P为季节性自回归阶数,D为季节差分阶数,Q为季节性移动平均阶数,s为季节模型的时间单位相应周期(本研究s=12)。
Deriv.com - Interday High Frequency Trading Models Comparison Review (Part II)中,结论1200分钟为最优数据量,故此我将数据量设置为(1200分钟,也就是等于20个交易小时),去预测下一分钟交易价格。
ts() &
auto.arima()source('函数/季节性自回归.R')
ts() &
auto.arima()ts() &
auto.arima()ts() &
auto.arima()# --------- eval=FALSE ---------
时间索引 <- unique(样本$日期)
基准 <- filter(样本, 年份 == 2016)$日期[1] #"2016-01-04" #第2年第1个交易日
时间索引 %<>% .[. >= 基准]
时间索引 %<>% .[1:6] #筛选数据中的前6个日期为样本
#时间索引 %<>% .[. >= as_date('2016-01-04')]
数据量 <- 1200 #筛选数据中的最后1200观测值:样本[(.N - (数据量 - 1)):.N]
预测时间单位 <- 1
.模型选项 = c('自动化', '自回归滑均')
# .模型选项 %<>% .[1]
# .模型选项 %<>% .[2]
.差分阶数 = 0:2
.季节性差分阶数 = 0:1
季节性与否 = c(TRUE, FALSE)
## https://stackoverflow.com/questions/37400062/seasonality-in-auto-arima-from-forecast-package
#近似值与否 = c(TRUE, FALSE)
#逐步精化与否 = c(TRUE, FALSE)
## .时序规律 = c(0, 0, 0)
.时序规律 = permutations(6, 3, 0:5, repeats.allowed = TRUE) %>%
as_tibble %>%
rename(自回归阶数 = V1, 差分阶数 = V2, 滑均阶数 = V3) %>%
filter(差分阶数 <= 2)
## .季节性规律参数 = c(0, 0, 0)
.季节性规律参数 = permutations(6, 3, 0:5, repeats.allowed = TRUE) %>%
as_tibble %>%
rename(季节性自回归阶数 = V1, 季节性差分阶数 = V2, 季节性滑均阶数 = V3) %>%
filter(季节性差分阶数 <= 1)
# --------- eval=FALSE ---------
llply(.模型选项, function(模型) {
if(模型 == '自动化') {
季回归0 <- llply(.差分阶数, function(差分阶数) {
季回归1 <- llply(.季节性差分阶数, function(季节性差分阶数) {
季回归2 <- llply(季节性与否, function(季节) {
季回归3 <- llply(时间索引, function(时序) {
成效 <- 季节性自回归(时间索引 = 时序, 样本 = 样本, 路径 = .路径,
数据量 = 数据量, 预测时间单位 = 预测时间单位, .模型选项 = 模型,
.差分阶数 = 差分阶数, .季节性差分阶数 = 季节性差分阶数,
季节性与否 = 季节, 静态与否 = FALSE, 记载自回归与否 = FALSE,
信息量准则 = c('aicc', 'aic', 'bic'),
逐步精化与否 = TRUE, 逐步精化量 = 94,
#近似值与否=(length(x)>150|frequency(x)>12),
缩写 = NULL, 计策谋略 = NULL, #x = y,
趋势 = NULL, 测试 = c('kpss', 'adf', 'pp'),
测试参数 = list(), 季节性测试参数 = list(),
季节性测试 = c('seas', 'ocsb', 'hegy', 'ch'),
允许截距与否 = TRUE, 允许包含均值与否 = TRUE, 博克斯考克斯变换 = NULL,
偏差调整与否 = FALSE, 多管齐下与否 = FALSE, 核心量 = 2)
})
})
})
})
} else if (模型 == 'Arima') {
季回归0 <- llply(1:nrow(.时序规律), function(迭数1) {
季回归1 <- llply(1:nrow(.季节性规律参数), function(迭数2) {
季回归2 <- llply(时间索引, function(时序) {
成效 <- 季节性自回归(时间索引 = 时序, 样本 = 样本, 路径 = .路径,
数据量 = 数据量, 预测时间单位 = 预测时间单位,
.模型选项 = 模型, .时序规律 = unlist(.时序规律[迭数1,]),
.季节性规律参数 = unlist(.季节性规律参数[迭数2,]), 趋势 = NULL,
允许包含均值与否 = TRUE, 允许截距与否 = FALSE,
#包含常数与否 = 包含常数与否,
#统计模型 = NULL, 博克斯考克斯变换 = 博克斯考克斯变换, x = y,
偏差调整与否 = FALSE, 计策谋略 = c('CSS-ML', 'ML', 'CSS'))
})
})
})
} else {
}
return(srm)
})
msts() &
auto.arima()fable &
fabletoolsarfima()msts()
& hw()After looking a bit more, I’ve came across this question where a user wanted to use the hw method to forecast half-hourly electricity demand using the taylor dataset available in the forecast package.
As Professor Rob Hyndman suggest in the response to the linked question, the double seasonal Holt Winters model method dshw from the forecast package can be used to deal with half-hourly data.
After removing the yearly seasonality parameter (seasonal.periods = 8760) in the definition of my msts object, I’ve ran the model and it provided a pretty accurate result.
How can I apply Seasonal Exponential Smoothing forecasting method to hourly data in R
msts()
& tbats()I set the length of data as weekly (7200 minutes which
is 5 trading days) to forecast 1440 minutes
(1440 minutes is a trading day).
Chapter 7 Multivariate TS Analysis in Introduction to Time Series Analysis and Forecasting in R, but I use univariate due to some errors as mentioned in beginning.
I tried to use weeks(1), months(1),
months(3), years(1) but there is not constant
observations, we can refer to The seasonal period.
Here I filter up the data as below :
5 days * 1440 mins = 7200 mins = weekly22 days * 1440 mins = 31680 mins = monthly3 months * 22 days * 1440 mins = 95040 mins =
quarterly52 weeks * 5 days * 1440 mins = 374400 mins =
yearlyI set the length of data as monthly
(22 days * 1440 mins = 31680 mins minutes which is 22
trading days), nested seasonal weekly
(5 days * 1440 mins = 7200 mins minutes which is 5 trading
days) and 1440 minutes (1440 minutes is a
trading day) to forecast 1440 minutes (1440
minutes is a trading day).
22 days * 1440 mins = 31680 mins5 days * 1440 mins = 7200 mins1440 mins1440 mins# --------- eval=FALSE ---------
时间索引 <- unique(样本$date)
基准 <- 样本[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
时间索引 %<>% .[. >= 基准]
#时间索引 %<>% .[. >= as_date('2016-01-04')]
数据量 <- 7200 #last 7200 observations 样本[(.N - (数据量 - 1)):.N]
预测时间单位 <- 1440
hrz2 <- 1440
llply(ets.m, function(模型) {
mstseas(时间索引 = 时间索引, 样本,
数据量 = 数据量, 预测时间单位 = 预测时间单位,
hrz2 = hrz2, .模型选项 = 模型)
})
I set the length of data as quarterly
(3 months * 22 days * 1440 mins = 95040 mins minutes which
is 66 trading days), nested seasonal weekly
(5 days * 1440 mins = 7200 mins minutes which is 5 trading
days) and 1440 minutes (1440 minutes is a
trading day) to forecast 1440 minutes (1440
minutes is a trading day).
3 months * 22 days * 1440 mins = 95040 mins5 days * 1440 mins = 7200 mins1440 mins1440 minsI set the length of data as yearly
(52 weeks * 5 days * 1440 mins = 374400 mins minutes which
is 260 trading days), nested seasonal weekly
(5 days * 1440 mins = 7200 mins minutes which is 5 trading
days) and 1440 minutes (1440 minutes is a
trading day) to forecast 1440 minutes (1440
minutes is a trading day).
52 weeks * 5 days * 1440 mins = 374400 mins5 days * 1440 mins = 7200 mins1440 mins1440 minsI set the length of data as quarterly
(3 months * 22 days * 1440 mins = 95040 mins minutes which
is 66 trading days), nested seasonal monthly
(22 days * 1440 mins = 31680 mins minutes which is 22
trading days) and 1440 minutes (1440 minutes
is a trading day) to forecast 1440 minutes
(1440 minutes is a trading day).
3 months * 22 days * 1440 mins = 95040 mins22 days * 1440 mins = 31680 mins1440 mins1440 minsVAR分析中的一个中心问题是找到滞后的阶数,以产生最佳结果。模型比较通常基于信息标准,例如AIC,BIC或HQ。通常,由于是小样本预测,AIC优于其他标准。但是,BIC和HQ在大型样本中效果很好
引用:R语言用向量自回归(VAR)进行经济数据脉冲响应研究分析
Here I read the saved models.
Due to the models only forecast 1440 mins (but not
7200 mins) in advance, here I no need to filter the
forecast price.
From final stage models comparison, we know that ******* is the βest model.
Next papers will compare tbats, midas,
sarimax etc.
以下乃此文书的文件信息。
#suppressMessages(require('formattable', quietly = TRUE))
#suppressMessages(require('knitr', quietly = TRUE))
#suppressMessages(require('kableExtra', quietly = TRUE))
#suppressMessages(require('magittr', quietly = TRUE))
#suppressMessages(require('devtools', quietly = TRUE))
系统信息1 <- session_info()$platform |>
unlist() |>
{\(.) data.frame(row.names = 1:length(.),
Category = names(.), session_info = .)}()
系统信息2 <- data.frame(Sys.info()) |>
{\(.) data.frame(Category = row.names(.), Sys.info = .[,1])}()
#remarks, dim(系统信息1), dim(系统信息2)
if (nrow(系统信息1) == 11 && nrow(系统信息2) == 8) {
系统信息2 <- 系统信息2 |>
{\(.) rbind(., data.frame(
Category = c('rmarkdown', 'rsconnect', '当前时间'),
Sys.info = c(as.character(getwd()),
as.character(packageVersion('rsconnect')),
paste(as.character(lubridate::now('Asia/Shanghai')), 'CST 中国标准时间 🗺'))))}()
} else if (nrow(系统信息1) == 10 && nrow(系统信息2) == 8) {
系统信息1 <- rbind(系统信息1, data.frame(Category = '', session_info = ''))
系统信息2 <- 系统信息2 |>
{\(.) rbind(., data.frame(
Category = c('rmarkdown', 'rsconnect', '当前时间'),
Sys.info = c(as.character(getwd()),
as.character(packageVersion('rsconnect')),
paste(as.character(lubridate::now('Asia/Shanghai')), 'CST 中国标准时间 🗺'))))}()
}
系统信息 <- cbind(系统信息1, 系统信息2)
names(系统信息) <- c('分类1', '访谈信息1', '分类2', '访谈信息2')
系统信息$分类1 <- c('版本', '操作系统', '系统', '界面', '语言', '核对', '©标准库', '时区', '日期', '®文艺坊版本', 'Pandoc瑞士军刀')
系统信息$分类2 <- c('系统名称', '发布', '版本', '元素节点', '机器', '登录', '用户', '活跃用户', 'rmarkdown (®降价编译)', 'rsconnect (®s联通)', '当前时间')
rm(系统信息1, 系统信息2)
系统信息 |>
{\(.)
kbl(., caption = '附加访谈信息:')}() |>
{\(.)
kable_styling(., bootstrap_options = c('striped', 'hover', 'condensed', 'responsive'))}() |>
{\(.)
row_spec(., 0, background = 'DimGrey', color = 'yellow')}() |>
{\(.)
column_spec(., 1, background = 'CornflowerBlue', color = 'red')}() |>
{\(.)
column_spec(., 2, background = 'grey', color = 'black')}() |>
{\(.)
column_spec(., 3, background = 'CornflowerBlue', color = 'blue')}() |>
{\(.)
column_spec(., 4, background = 'grey', color = 'white')}() |>
{\(.)
row_spec(., 11, bold = TRUE, color = 'yellow', background = '#D7261E')}()
| 分类1 | 访谈信息1 | 分类2 | 访谈信息2 |
|---|---|---|---|
| 版本 | R version 4.2.0 (2022-04-22) | 系统名称 | Linux |
| 操作系统 | Ubuntu 22.04 LTS | 发布 | 5.15.0-40-generic |
| 系统 | x86_64, linux-gnu | 版本 | #43-Ubuntu SMP Wed Jun 15 12:54:21 UTC 2022 |
| 界面 | X11 | 元素节点 | ScibrokesTrading |
| 语言 | cn | 机器 | x86_64 |
| 核对 | en_US.UTF-8 | 登录 | englianhu |
| ©标准库 | en_US.UTF-8 | 用户 | englianhu |
| 时区 | Asia/Shanghai | 活跃用户 | englianhu |
| 日期 | 2022-06-24 | rmarkdown (®降价编译) | /home/englianhu/Documents/GitHub/binary.com-interview-question |
| ®文艺坊版本 | 2.17.1.1 @ /usr/lib/rstudio/bin/quarto/bin/ (via rmarkdown) | rsconnect (®s联通) | 0.8.26 |
| Pandoc瑞士军刀 | 当前时间 | 2022-06-24 06:08:52 CST 中国标准时间 🗺 |
ARCH in MeanARIMA(p,d,q)参数最优化
Sςιβrοκεrs Trαdιηg®
世博量化®企业知识产权及版权所有,盗版必究。